import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const USER = "USER";
const CART_COUNT = "CART_COUNT";
const store = new Vuex.Store({
  state: {
    user: SessionStorage.get(USER) || {},
    cartCount: SessionStorage.get(CART_COUNT) || 0,
  },
  mutations: {
    setUser (state, user) {
      state.user = user;
      SessionStorage.set(USER, user);
    },
    setCartCount (state, cartCount) {
      state.cartCount = cartCount;
      SessionStorage.set(CART_COUNT, cartCount);
    }
  },
  actions: {
  },
  modules: {
  }
});

export default store